<!DOCTYPE>
<html>
<head>
<meta  charset=utf-8" />
<title>用PHP创建新数据库和表</title>
</head>
<body>
<?php
if(trim ($_POST['password'])!=trim($_POST['repassword'])){
	 exit('两次密码不一致，请重输')
 }
$con = mysql_connect("localhost","root","");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

// Create database
if (mysql_query("CREATE DATABASE my_db",$con))
  {
  echo "Database created";
  }
else
  {
  echo "Error creating database: " . mysql_error();
  }

// Create table in my_db database
mysql_select_db("my_db", $con);
$sql = "CREATE TABLE Persons 
(
username varchar(15),
password varchar(15),
emal varchar(15),
phen varchar(15)
)";
mysql_query($sql,$con);

mysql_close($con);
?>
</body>
</html>